package thinkingJava.chapter11;

import java.util.Iterator;

import thinkingJava.chapter14.Pet;
import thinkingJava.chapter14.Pets;

class PetSequence {
	protected Pet[] pets = Pets.createArray(8);
}
public class NonCollectionSequence extends PetSequence {
	public Iterator<Pet> iterator() {
		return new Iterator<Pet>(){
			private int index = 0;
			public boolean hasNext() {
				return index < pets.length;
			}
			public Pet next() {
				return pets[index++];
			}
			public void remove() {
				throw new UnsupportedOperationException();
			}
		};
	}
	public static void main(String[] args) {
		NonCollectionSequence ncs = new NonCollectionSequence();
		InterfaceVsIterator.display(ncs.iterator());
	}
}
